/* QtLua -- Lua bindings for Qt
   Copyright (C) 2011, Jarek Pelczar

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA

*/

#ifndef QLUASCRIPTENGINEDEBUGGER_H
#define QLUASCRIPTENGINEDEBUGGER_H

#include <QObject>
#include <QMainWindow>
#include <QToolBar>
#include "qluascriptengine.h"

class QLuaScriptEngineDebuggerPrivate;

class QLuaScriptEngineDebugger : public QObject
{
    Q_OBJECT
public:
    enum DebuggerWidget {
        ConsoleWidget,
        StackWidget,
        ScriptsWidget,
        LocalsWidget,
        CodeWidget,
        CodeFinderWidget,
        BreakpointsWidget,
        DebugOutputWidget,
        ErrorLogWidget
    };

    enum DebuggerState {
        RunningState,
        SuspendedState
    };

    enum DebuggerAction {
        InterruptAction,
        ContinueAction,
        StepIntoAction,
        StepOverAction,
        StepOutAction,
        RunToCursorAction,
        RunToNewScriptAction,
        ToggleBreakpointAction,
        ClearDebugOutputAction,
        ClearErrorLogAction,
        ClearConsoleAction,
        FindInScriptAction,
        FindNextInScriptAction,
        FindPreviousInScriptAction,
        GoToLineAction
    };

    explicit QLuaScriptEngineDebugger(QObject *parent = 0);
    ~QLuaScriptEngineDebugger();

    void attachTo(QLuaScriptEngine * engine);
    void detach();
    bool autoShowStandardWindow() const;
    void setAutoShowStandardWindow(bool autoShow);

    QMainWindow * standardWindow() const;
    QWidget * debuggerWidget(DebuggerWidget widget) const;
    DebuggerState state() const;
    QAction * action(DebuggerAction action) const;
    QMenu * createStandardMenu(QWidget * parent = 0) const;
    QToolBar * createStandardToolBar(QWidget * parent = 0) const;

signals:
    void evaluationResumed();
    void evaluationSuspended();

private:
    friend class QLuaScriptEngineDebuggerPrivate;
    QLuaScriptEngineDebuggerPrivate * d;
    Q_PRIVATE_SLOT(d, void _q_showStandardWindow())
};

#endif // QLUASCRIPTENGINEDEBUGGER_H
